package com.zhenyi.tuangou.index;

import java.util.List;

import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import com.zhenyi.common.model.TgShop;

public class ShopControll extends TGController{

	public void index(){
		TgShop tgShop =  TgShop.dao.findById(1802);
		String[] images = getImages(tgShop.getLogo());
		
		Integer type = getParaToInt("type");// 默认全部类型
		SqlPara sqlPara;
		if (type != null) {
			Kv cond = Kv.by("type", type);
			sqlPara = Db.getSqlPara("findProductByType", cond);
		} else {
			sqlPara = Db.getSqlPara("findProductByType");
		}
		// 商品列表
		List<Record> list = Db.find(sqlPara);
		
		setAttr("images", images);// 轮播图url
		setAttr("shop", tgShop);//商店信息
		setAttr("items", list);
		render("/res/index.html");
	}
}
